#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
const int N = 1010, M = 110;
int f[M][M];
int v[N], m[N], w[N];
int n, max_v, max_m;
int main()
{
    cin >> n >> max_v >> max_m;
    for (int i = 1; i <= n; i++) cin >> v[i] >> m[i] >> w[i];
    for (int i = 1; i <= n; i++)
    {
        for (int j = max_v; j >= v[i]; j--)
        {
            for (int k = max_m; k >= m[i]; k--)
            {
                f[j][k] = max(f[j][k], f[j - v[i]][k - m[i]] + w[i]);
            }
        }
    }
    cout << f[max_v][max_m];
    return 0;
}